package com.codi.bus.core.service.impl;

import com.codi.base.domain.BaseResult;
import com.codi.bus.core.dao.BankLimitDao;
import com.codi.bus.core.domain.BankLimit;
import com.codi.bus.core.service.BankLimitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service("bankLimitService")
@Transactional(readOnly = true)
public class BankLimitServiceImpl implements BankLimitService{
    @Autowired
    private BankLimitDao bankLimitDao;

    @Override
    public List<BankLimit> selectAll() {
        return bankLimitDao.selectAll();
    }

    @Override
    public List<BankLimit> selectAllByState() {
        return bankLimitDao.selectAllByState();
    }

    @Override
    public BaseResult selectOne(Integer id) {
        return BaseResult.success(bankLimitDao.selectOne(id));
    }

    @Override
    @Transactional(readOnly = false)
    public BaseResult add(BankLimit bankLimit) {
        bankLimitDao.add(bankLimit);
        return BaseResult.success();
    }

    @Override
    @Transactional(readOnly = false)
    public BaseResult delete(Integer id) {
        bankLimitDao.deleteById(id);
        return BaseResult.success();
    }

    @Override
    @Transactional(readOnly = false)
    public BaseResult update(BankLimit bankLimit) {
        bankLimitDao.update(bankLimit);
        return BaseResult.success();
    }

    @Override
    public BankLimit selectByCodeAndChannel(String code, String channel) {
        return bankLimitDao.selectByChannelAndCode(code, channel);
    }
}
